<template>
  <div class="yaliChart_main_container grid">
    <!-- {{ paramsData }} -->
    <div
      class="detail-item x22"
      v-for="(value, key, index) in clickDetail"
      :key="index"
    >
      <span>{{ clickDetail[key] }}：</span>

      <span
        >{{ dataList[key] != null && dataList[key] != "" ? dataList[key] : "/"
        }}{{ dataList[key] ? unit[key] : "" }}</span
      >
    </div>
  </div>
  <!-- <div>
        <h2>2x3</h2>
        <div class="grid">
        <div class="x23">first</div>
        <div class="x23">second</div>
        <div class="x23">third</div>
        <div class="x23">fourth</div>
        <div class="x23">fifth</div>
        <div class="x23">sixth</div>
        </div>
        <h2>2x2</h2>
        <div class="grid">
        <div class="x22">first</div>
        <div class="x22">second</div>
        <div class="x22">third</div>
        <div class="x22">fourth</div>
        </div>
    </div> -->
</template>

<script>
import { clickDetailObj, unitList } from "@/until/NameList";
import { getPOIDetail, queryShouFeiZhanData } from "@/api/apiPOI";
export default {
  name: "YaLiChart",
  components: {},
  created() {},
  props: {
    paramsData: {
      type: Object,
      default: function () {
        return {};
      },
    },
  },
  watch: {
    paramsData: {
      handler(newVal, oldVal) {
        console.log("*****Detail*********", newVal);

        if (newVal && newVal.hasOwnProperty("sttp")) {
          if (newVal.sttp == "4") {
            return;
          } else if (newVal.sttp == "5") {
            queryShouFeiZhanData({ orgId: newVal.deviceId }).then((res) => {
              console.log(res, "=====");
              // if(res)
              res.forEach((element) => {
                if (element.org_id == newVal.deviceId) {
                  this.dataList = element;
                  this.$parent.titleText = element.org_name;
                }
              });
            });
          } else {
            let params = {
              deviceId: newVal.deviceId,
            };
            newVal.sttp != "0" && (params.sttp = newVal.sttp);
            getPOIDetail(params).then((res) => {
              let paramType = (value, type) =>
                Object.prototype.toString.call(value).includes(type);
              if (paramType(res, "Object")) {
                this.dataList = res;
                // 更新测站详情显示的字段
                this.clickDetail = clickDetailObj[this.dataList.sttp || 3];
                this.$parent.titleText = res.addressName;
              }
            });
          }
        }
      },
      immediate: true,
    },
  },
  data() {
    return {
      clickDetail: clickDetailObj[3],
      dataList: {
        loc: "巉口",
        iskd: "0",
        mnf: 1,
        installMan: "薛琳",
        installDate: "2022-08-10",
        addressName: "输水西干一级供水北干管一分干五支管(CK1-8)",
        lon: 104.463691,
        sttp: "0",
        deviceId: "621102008",
        lat: 35.6489488,
      },
      unit: unitList,
    };
  },

  methods: {},
};
</script>

<style lang="scss" scoped>
.yaliChart_main_container {
  padding: 18px 0;
}
.detail-item {
  display: flex;
  justify-content: flex-start;
  padding: 6px 0;
  //   border: 1px solid #daf0ff;
  //   background-color: rgba(123,148,214,0.5);

  span:nth-child(2n + 1) {
    width: 110px;
    text-align: right;
    font-family: SourceHanSansCN-Regular;
    font-size: 12px;
    font-weight: normal;
    font-stretch: normal;
    line-height: 18px;
    letter-spacing: 0px;
    color: #daf0ff;
  }

  span:nth-child(2n) {
    font-size: 12px;
    font-weight: normal;
    font-stretch: normal;
    line-height: 18px;
    letter-spacing: 0px;
    color: #00baff;
  }
}

.grid {
  // border: 1px solid gray;
  // width: 400px;
  // height: 200px;
  grid-gap: 1px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  // grid-template-rows: repeat(2, 49%);
  overflow: hidden;
}

.grid .x22,
.grid .x23 {
  // background-color: #1c1c1c;
  // color: white;
  // font-weight: bold;
  // display: -webkit-box;
  // display: -ms-flexbox;
  // display: flex;
  // -webkit-box-pack: center;
  // -ms-flex-pack: center;
  // justify-content: center;
  // -webkit-box-align: center;
  // -ms-flex-align: center;
  // align-items: center;
}

.grid .x22 {
  grid-column: span 2;
}

.grid .x23 {
  grid-column: span 2;
}
</style>
